package vn.sunnet.backviet01.game.coloa.util.mypool;

import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.util.pool.GenericPool;

import vn.sunnet.backviet01.game.coloa.human.enemy.MagicOfSpell;

public class MagicOfSpellPool extends GenericPool<MagicOfSpell>{
	private final TextureRegion mTextureRegion;

	public MagicOfSpellPool(final TextureRegion pTextureRegion) {
		if (pTextureRegion == null) {
			throw new IllegalArgumentException("The texture region must not be NULL");
		} 
		mTextureRegion = pTextureRegion;
	}
	
	@Override
	protected MagicOfSpell onAllocatePoolItem() {
		// TODO Auto-generated method stub
		return new MagicOfSpell(0, 0, mTextureRegion.deepCopy());
	}
	
	protected void onHandleRecycleItem(final MagicOfSpell magicOfSpell) {
		magicOfSpell.setIgnoreUpdate(true);
		magicOfSpell.clearEntityModifiers();
		magicOfSpell.clearUpdateHandlers();
		magicOfSpell.setVisible(false);
		magicOfSpell.detachSelf();
		magicOfSpell.reset();
	}
}
